#ifndef __util_h__
#define __util_h__

#include <cstddef>

#ifdef _WIN32
typedef int ssize_t;
typedef int mode_t;
#endif

extern const int util_stdin;
extern const int util_stdout;
extern const int util_stderr;

extern const int util_rdonly;
extern const int util_wronly;
extern const int util_creat;
extern const int util_trunc;
extern const int util_append;

int util_printf(const char * _format, ...);

size_t util_dehttpize(char * _text, size_t _length) throw();
char * util_htmlize(const char * _in, size_t _size) throw();

int util_open(const char * _pathname, int _flags, mode_t _mode = 0644) throw();
int util_close(int _d) throw();

ssize_t	util_readn(int _d, char * _buf, size_t _cnt) throw();
ssize_t util_writen(int _d, const char * _buf, size_t _cnt) throw();

bool util_isdir(mode_t mode) throw();
int util_access(const char * _pathname, mode_t _mode) throw();

int util_stat(const char * _pathname, struct stat * _st) throw(); 
int util_fstat(int _d, struct stat * _st) throw();

int util_setbinmode(int fd) throw();

time_t util_time() throw();
const char * util_ctime() throw();

bool util_isspace(char _c) throw();
bool util_isalpha(char _c) throw();
bool util_isdigit(char _c) throw();

#endif //__util_h__
